/*
 *    Copyright © OpenAtom Foundation.
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package com.inspur.edp.bef.dtgenerator;

import com.inspur.edp.jittojava.context.JitContext;
import com.inspur.edp.jittojava.spi.JitAction;
import java.util.HashMap;

public class BEJitAction implements JitAction {
  @Override
  public void generateApi(JitContext context) {
    BEGenerator beGen =
        new BEGenerator(
            context.getMetadata().getRelativePath(),
            context.getMetadata(),
            true,
            context.getApiModuleGenerator(),
            context);
    context.getApiModuleGenerator().addExtendChildGenrator(beGen);
    if (context.getExtendProperty() == null) {
      context.setExtendProperty(new HashMap<>());
    }
    context.getExtendProperty().put(context.getMetadata().getHeader().getId() + "GenCtx", beGen);
  }

  @Override
  public void generateCore(JitContext context) {
    BEGenerator begen =
        (BEGenerator)
            context.getExtendProperty().get(context.getMetadata().getHeader().getId() + "GenCtx");
    BEGenerator beGen =
        new BEGenerator(
            context.getMetadata().getRelativePath(),
            context.getMetadata(),
            begen.getContext(),
            context.getCoreModuleGenerator(),
            context);
    context.getCoreModuleGenerator().addExtendChildGenrator(beGen);
  }

  //	public final void  beforeCsprojCompile(MetadataJitContext context)
  //	{
  //		BEGenerator beGen = new BEGenerator(context.Metadata.RelativePath, context.Metadata, true,
  // null,
  // context.ApiGenerator, context);
  //		context.ApiGenerator.AddChildGenerator(beGen);
  //		if (context.ExtendProperty == null)
  //		{
  //			context.ExtendProperty = new java.util.HashMap<String, Object>();
  //		}
  //		context.ExtendProperty.Add($"{((GspBusinessEntity)context.Metadata.Content).ID}GenCtx",
  // beGen);
  //	}
  //
  //	public final void  afterCsprojCompile(MetadataJitContext context)
  //	{
  //		BEGenerator begen =
  // (BEGenerator)((context.ExtendProperty[$"{((GspBusinessEntity)context.Metadata.Content).ID}GenCtx"] instanceof BEGenerator) ? context.ExtendProperty[$"{((GspBusinessEntity)context.Metadata.Content).ID}GenCtx"] : null);
  //		BEGenerator beGen = new BEGenerator(context.Metadata.RelativePath, context.Metadata,
  // begen.getContext(), null, context.CoreGenerator, context);
  //		beGen.SetProjectApiAssembly(context.ApiProjectAssembly);
  //		context.CoreGenerator.AddChildGenerator(beGen);
  //	}
  //
  //	@Override
  //	public void  fireDoSomethingAfterApiGenerator(MetadataJitContext context)
  //	{
  //	}
  //
  //	@Override
  //	public void  fireDoSomethingAfterCoreGenerator(MetadataJitContext context)
  //	{
  //	}
}
